﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ModbusTCPDemo
{
    public partial class FrmOperation : Form
    {
        public FrmOperation()
        {
            InitializeComponent();
            this.cmb_Type.Items.Add("Boolean");
            this.cmb_Type.Items.Add("Int");
            this.cmb_Type.Items.Add("Float");
        }
        public OperationItem item;
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.txt_Address.Text.Trim().Length > 0 && this.cmb_Type.Text.Trim().Length > 0 && this.txt_Value.Text.Trim().Length > 0)
            {
                 item = new OperationItem()
                {
                    Address = Convert.ToInt32(this.txt_Address.Text.Trim()),
                    Value =  this.txt_Value.Text.Trim(),
                    Type = this.cmb_Type.SelectedIndex
                };
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("请检查输入数据是否正确！");
            }
        }

        private void btn_Cannel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
